/**
 * @description:
 * @author: 啸
 * @email: zhang_6379@sina.com
 * @date: 2021/11/4 19:08
 */
public class leecode_question04 {
    public static void main(String[] args) {
        leecode_question04 lee = new leecode_question04();
        //方法一
//        System.out.println(lee.palindromicNumber01(121));
        //方法二
        System.out.println(lee.palindromicNumber02(121));
    }

    //方法一：
    boolean palindromicNumber01(int num){
        String str = ""+num;
        String result = "";
        for (int i = str.length()-1; i >=0 ; i--){
             result = result +""+str.charAt(i);
        }
        System.out.println(result);
        return str.equals(result);
    }
    //方法二：
    boolean palindromicNumber02(int num){
        if (num < 0 || (num % 10 == 0 && num != 0)){
            return false;
        }
        int flag = 0;
        while (num > flag){
            flag = flag * 10 + num % 10;
            num /= 10;
        }
        return num == flag || num == flag / 10;
    }

}
